﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ClassLibrary;
using System.ServiceModel;

namespace Server
{
    class Program
    {
        public static List<IClientContract> Clients { get; set; }
        public static List<Match> Matchs { get; internal set; }

        static void Main(string[] args)
        {
            InitMatchs();
            try
            {
                ServiceHost serviceHost = new ServiceHost(typeof(Server));
                serviceHost.AddServiceEndpoint(typeof(IServerContract), new WSDualHttpBinding(), "http://localhost:8090/TheBestPlayer");

                serviceHost.Open();
                Console.WriteLine("Server started");
            }
            catch (Exception e)
            {
                Console.WriteLine("Server failed");
                Console.WriteLine(e.Message);
            }


            Console.ReadLine();
        }

        static void InitMatchs()
        {
            Matchs = new List<Match>()
            {
                new Match()
                {
                    MatchDate = DateTime.Now,
                    TeamAway = new Team()
                    {
                        Name = "Gigis",
                        Players = new List<Player>()
                        {
                            new Player() { FirstName = "Paul", LastName = "Bernardoni" }
                        }
                    },
                    TeamHome = new Team()
                    {
                        Name = "Paris",
                        Players = new List<Player>()
                        {
                            new Player() { FirstName = "Kevin", LastName = "Trapp" }
                        }
                    },
                }
            };
        }
    }
}
